var treeJson = {
    setTree: function (str, where) {
        var tree = "#" + str;
        $.fn.zTree.destroy(where);
        var getdata = $("#" + where).val();
        var setting = {};
        var pobj = eval("(" + getdata + ")");
        var jdata = [];
        console.info(str);
        console.info(getdata);
        jdata.push({name: "JSON", open: true, children: treeJson.getALL(pobj)});
        $.fn.zTree.init($(tree), setting, jdata);

    },
    getALL: function (obj) {
        var content = [];
        for (var name in obj) {
            var val = obj[name];
            if (val === null) {
                content.push({name: "\"" + name + "\"" + ":NULL"});
            } else {
                var con = val.constructor;
                if (con == Array) {
                    content.push({name: "\"" + name + "\"", children: treeJson.getALL(val)});
                } else if (con == String || con == Date) {
                    content.push({name: "\"" + name + "\"" + ":" + "\"" + val + "\""});
                } else if (con == Number || con == Boolean) {
                    content.push({name: "\"" + name + "\"" + ":" + val});
                } else {
                    content.push({name: "\"" + name + "\"", children: treeJson.getALL(val)});
                }
            }

        }
        return content;

    },
    getSelected: function (str) {
        var manager = $("#" + str).ligerGetTreeManager();
        var note = manager.getSelected();
        var data = note["data"];
        var a = data["children"];
        if (a === null) {
            alert(note.data.name);
        }
    }
};